# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=xerces-c
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.2.3
pkgrel=2
pkgdesc="A validating XML parser written in a portable subset of C++ (mingw-w64)"
arch=('any')
url="https://xerces.apache.org/xerces-c"
license=("APACHE")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         # "${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-icu")
options=('staticlibs' 'strip')
source=("https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-${pkgver}.tar.gz"
        001-no-undefined.patch
        002-duplicate-instantiation.patch)
sha256sums=('fb96fc49b1fb892d1e64e53a6ada8accf6f0e6d30ce0937956ec68d39bd72c7e'
            'a95206b0e17942ebe5bffcafbb9c9555b1f3c922b9a8f7cdea950acab48eecd5'
            '028b0a5c021d63c74db24bfca898c9e6df7074c1597896a6bfd48d76f64b9cb8')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  patch -p1 -i ${srcdir}/002-duplicate-instantiation.patch
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
